package main

import (
	"fmt"
	"time"
)

func test1() {
	for i := 0; i < 5; i++ { //最终 i = 5 进入匿名函数
		go func() {
			fmt.Println(i)
		}()
	}
	time.Sleep(time.Second)
}
func main() {
	//test1()
	test2()
}

func test2() {
	for i := 0; i < 5; i++ {
		go func(index int) {
			fmt.Println(index)
		}(i)
	}
	time.Sleep(time.Second)
}
